import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

type Result = {
  data: any;
  status: number;
  msg: string;
  success: boolean;
};

type ResultOrganization = {
  success: boolean;
  data?: {
    list: Array<any>;
    totalCount: number;
  };
};

interface getplanlist {
  status: number;
  msg: string;
  data: {
    planId: string;
    planName: string;
    createUser: string;
    createTime: string;
    modificationTime: string;
    isGenerate: number;
    remarks: string;
    importPlanId: string;
    modelRemark: string;
  };
  success: boolean;
}

/** 获取计划列表 */
export const PlanGetPage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/Plan/GetAllByPagedAndSort"), {
    params
  });
};

//保存机构
export const PlanSave = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/Plan/Save"), {
    data
  });
};

//删除机构
export const PlanDelete = (params?: object) => {
  return http.request<Result>("post", baseUrlApi("/Plan/Delete"), {
    params
  });
};

// 查询所有机构
export const GetAllPlan = () => {
  return http.request<ResultOrganization>(
    "get",
    baseUrlApi("/Plan/GetAllPlan")
  );
};

// 根据班级id获取计划列表
export const GetPlanByClassId = (params?: string) => {
  return http.request<getplanlist>(
    "get",
    baseUrlApi("/Plan/GetPlanByClassId?" + params)
  );
};

//获取学生个人成绩
export const GetThatPersonAchievement = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/Achievement/GetThatPersonAchievement"),
    {
      data
    }
  );
};

//导出学生成绩
export const ExportThatPerson = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/Achievement/ExportThatPerson"),
    {
      data
    }
  );
};
//获取团队成绩
export const GetTeamAchievement = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/Achievement/GetTeamAchievement"),
    {
      data
    }
  );
};

//答案查询
export const GetScoreDetail = (params?: string) => {
  return http.request<any>(
    "get",
    baseUrlApi("/IntelligentEvaluation/GetScoreDetail?" + params)
  );
};

// 获取模板列表

export const PlanGetTemplatePlan = (params?: string) => {
  return http.request<any>(
    "get",
    baseUrlApi("/Plan/GetTemplatePlan?" + params)
  );
};

// 导入模板计划
export const PlanImportTemplatePlan = (params?: string) => {
  return http.request<any>(
    "get",
    baseUrlApi("/Plan/ImportTemplatePlan?" + params)
  );
};
